package io.github.kimmking.gateway.router.my;

import io.github.kimmking.gateway.router.HttpEndpointRouter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 *
 */
@Slf4j
public class MyHttpEndpointRouterDelegate implements HttpEndpointRouter {

    private HttpEndpointRouter router;

    @Setter
    private boolean logEnable = true;

    public MyHttpEndpointRouterDelegate(HttpEndpointRouter router) {
        this.router = router;
    }

    @Override
    public String route(List<String> endpoints) {
        String routeEndPoint = router.route(endpoints);
        if (logEnable) {
            log.info("router:{}, target endpoint is :{}", router.getClass().getName(), routeEndPoint);
        }
        return routeEndPoint;
    }
}
